﻿using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using ERP.Business.DataTypes.Users.Credentials;

namespace ERP.UI.SystemAdministrator
{
    /// <summary>
    /// Login form
    /// </summary>
    public partial class Login
    {
        #region Constructors

        /// <summary>
        /// Default constructor
        /// </summary>
        public Login()
        {
            this.InitializeComponent();
            // Insert code required on object creation below this point.
        }
        #endregion

        #region Event handlers

        /// <summary>
        /// Login control cancel handler
        /// </summary>
        private void Login_CancelButtonClick(object sender, RoutedEventArgs e)
        {
            Close();
        }

        /// <summary>
        /// Login control login handler
        /// </summary>
        private void Login_LoginButtonClick(object sender, RoutedEventArgs e)
        {
            //CredentialsServiceReference.CredentialsServiceClient client = new ERP.UI.SystemAdministrator.CredentialsServiceReference.CredentialsServiceClient();
            //CredentialStatus status = client.GetUserCredential(loginControl.Username, loginControl.Password, ApplicationVariables.ApplicationID);
            //client.Close();

            //if (status == CredentialStatus.AccessDenied)
            //{
            //    loginControl.ShowFailureText = true;
            //}
            //else
            //{
            //    DialogResult = true;
            //    UpdateLoggedUser();
            //    Close();
            //}
        }

        private void UpdateLoggedUser()
        {
            //UsersServiceReference.UsersServiceClient client = new ERP.UI.SystemAdministrator.UsersServiceReference.UsersServiceClient();
            //ApplicationVariables.CurrentUser = client.GetUserByUsername(loginControl.Username);
            //client.Close();
        }
        #endregion

    }
}